"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var address_service_1 = require("../../lib/service/address.service");
var api_1 = require("config/api");
var AddContact = /** @class */ (function () {
    function AddContact() {
        this.province = 0;
        this.city = 0;
        this.type = '意向代理';
    }
    return AddContact;
}());
exports.AddContact = AddContact;
var PartnerComponent = /** @class */ (function () {
    function PartnerComponent(addressService, httpService) {
        this.addressService = addressService;
        this.httpService = httpService;
        this.isShow = false;
        this.provinceList = [];
        this.cityList = [];
        this.productNum = 0;
        this.addContact = new AddContact;
    }
    PartnerComponent.prototype.ngOnInit = function () {
        this.productCirculation();
        this.getProvinceList();
    };
    // 获取省列表
    PartnerComponent.prototype.getProvinceList = function () {
        var _this = this;
        this.addressService.getProvinceList()
            .subscribe(function (res) {
            _this.provinceList = res.data;
        });
    };
    // 更改省之后
    PartnerComponent.prototype.changeProvince = function () {
        var _this = this;
        this.addContact.city = 0;
        this.addressService.getCityList(this.addContact.province).subscribe(function (res) {
            _this.cityList = res.data;
        });
    };
    PartnerComponent.prototype.productCirculation = function () {
        var _this = this;
        setInterval(function () {
            _this.productNum += 1;
            if (_this.productNum > 4) {
                _this.productNum = 0;
            }
        }, 2000);
    };
    // 代理商提交联系方式
    PartnerComponent.prototype.contactSubmit = function () {
        var _this = this;
        if (!this.addContact.city) {
            this.type = 'info';
            this.message = '请选择您的所在地';
            this.isShow = true;
            return;
        }
        var url = api_1.adSystemApiUrl + "/v1/fddata/applet_apply/add";
        return this.httpService.httpPostAuth(url, this.addContact).subscribe(function (res) {
            if (res.code === 2000) {
                _this.type = 'success';
                _this.message = '提交成功';
                _this.isShow = true;
            }
            else {
                _this.type = 'error';
                _this.message = res.message;
                _this.isShow = true;
            }
        });
    };
    PartnerComponent = __decorate([
        core_1.Component({
            selector: 'app-partner',
            templateUrl: './partner.component.html',
            styleUrls: ['./partner.component.scss'],
            providers: [address_service_1.AddressService]
        })
    ], PartnerComponent);
    return PartnerComponent;
}());
exports.PartnerComponent = PartnerComponent;
